<!--
 * @Description:淘宝轮播图
 * @Author: Sun
 * @Date: 2019-07-01 20:05:50
 * @LastEditors: Sun
 * @LastEditTime: 2019-07-07 16:34:53
 -->
<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>多物体运动.html</title>
	<script src="./move3.js"></script>
	<style>
		* {
			margin: 0;
			padding: 0;
		}

		#div1 {
			width: 100px;
			height: 50px;
			background: red;
			margin: 10px;
		}

		.potu {
			position: absolute;
			overflow: hidden;
			width: 400px;
			top: 0;
			/* height: 260px; */
		}

		.potu li {
			width: 400px;
			height: 260px;
		}

		.potu li img {
			width: 400px;
			height: 260px;
		}

		.active {
			background: darkturquoise;
			color: #000;
		}

		.ol {
			overflow: hidden;
			position: absolute;
			right: 60px;
			bottom: 20px;
			z-index: 20;
		}

		.ol li {
			float: left;
			width: 30px;
			height: 30px;
		}

		#play {
			width: 400px;
			height: 260px;
			overflow: hidden;
			position: relative;
			margin: 20px auto;
		}
	</style>
	<script>
		window.onload = function () {
			var odiv = document.getElementById('play')
			var aBtn = document.getElementById('pl').getElementsByTagName('li')
			var oul = document.getElementById('pout')
			var now=0;
			for (let index = 0; index < aBtn.length; index++) {
				const element = aBtn[index];
				aBtn[index].indext = index
				element.onclick = function () {
					now = this.indext;
					tab()
				}
			}

			function tab() {
				for (let index1 = 0; index1 < aBtn.length; index1++) {
					const element1 = aBtn[index1];
					element1.className = '';
				}
				aBtn[now].className = 'active'
				startmove(oul, {
					'top': -260 * now
				})
			}

			function next() {
				now++;
				if (now == aBtn.length) {
					now = 0;
				}
				tab()
			}

		var timer=setInterval(
				next, 2000
			)

		odiv.onmouseover=function(){
			clearInterval(timer)
		}
		odiv.onmouseout=function(){
			timer=setInterval(
			next, 2000
			)
		}

		}
	</script>
</head>

<body>
	<div class="play" id="play">
		<ul class="ol" id="pl">
			<li class="active">1</li>
			<li>2</li>
			<li>3</li>
			<li>4</li>
			<li>5</li>
		</ul>
		<ul class="potu" id="pout">
			<li><img src="./img/1.jpg" alt=""></li>
			<li><img src="./img/2.jpg" alt=""></li>
			<li><img src="./img/3.jpg" alt=""></li>
			<li><img src="./img/4.png" alt=""></li>
			<li><img src="./img/1562369461216.jpg" alt=""></li>
		</ul>

	</div>

</body>

</html>